#include<stdio.h>
#include<stdlib.h>
int main()
{
	int i,j,time,n,l,k,y,min=100000;
	char line[100];
	scanf("%d %d %d %d",&n,&l,&k,&y);
	for(i=0;i<n;i++)
	{
		time=0;
		gets(line);
		for(j=0;line[j]!='\0';j++)
		{
			if(line[j]=='A') time=time+l+k+y;
			else if(line[j]=='B') time=time+2*l+k;
			else time=time+3*l+3*k+2*y;
		}
		printf("%d",time);
		if(min>time)
		{
			min=time;
		}
	}
	printf("%d",min);
	return 0;
}

